<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<title>招标检索</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/css/datatable.css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/api.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/common.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.dataTables.chs.js"></script>
<script type="text/javascript">
$(function() {
    
    var urlPrefix = "${pageContext.request.contextPath}/api/";
    
    var table = $('#search_result').DataTable({
		paging: true,
		pageLength: 20,
		pagingType: 'full_numbers',
		lengthChange: false,
		searching: false,
		info: true,
		jQueryUI: false,
		ordering: false,
		autoWidth: false,
		columns: [
			{data:'tender_title', width:'60%', render: function(data, type, full, meta) {
			    return '<a href="${pageContext.request.contextPath}/forward/tender_detail?tenderId=' + full.tender_id + '" target="_blank">' + data + '</a>';
			}},
			{data:'tender_no', width:'20%', className: 'dt-body-center'},
			{data:'create_date', width:'20%', className: 'dt-body-center'}
		],
		serverSide: true,
		processing: true,
		ajax: {
			url: '${pageContext.request.contextPath}/api/TenderSearchAPI.json',
			type: 'POST',
			data: function(d) {
			    var paramData = {};
			    if ($('#keyword').val()) {
		            paramData.tender_title = $('#keyword').val();
		        }
		        if ($('#status').val()) {
		            paramData.status = new Array($('#status').val());
		        }
		        if ($('#time_limit').val()) {
		            paramData.time_limit = $('#time_limit').val();
		        } else {
		            paramData.time_limit = 1;
		        }
			    d.param = JSON.stringify(paramData);
			},
			dataSrc: 'tenders'
		}
	});
    
    $.codeNameCombo({
        urlPrefix: urlPrefix,
        typeId: '12',
        target: '#time_limit',
        value: '1',
        onChange: function(newValue, oldValue) {
        }
    });
    
    $.codeNameCombo({
        urlPrefix: urlPrefix,
        typeId: '08',
        target: '#status',
        blank: true,
        blankValue: '',
        blankText: '全部',
        onChange: function(newValue, oldValue) {
        }
    });
    
    $('#btn_search').click(function() {
        table.ajax.reload();
    });
});
</script>
</head>
<body>
  <div style="text-align: center;" align="center">
    <jsp:include page="top.jsp" />
    <div id="content" style="width: 1000px; margin: 0 auto; margin-top: 10px; ">
      <label style="text-align: left; font-size: 15px; font-weight: bold; font-style: italic; width: 100%; height: 30px; text-shadow: 2px 2px 1px #ccc; float: left; margin-top: 5px;">&nbsp;&nbsp;招标检索</label>
      <hr style="height: 1px; border: 1px dashed #ccc;">
      <div style="width: 100%; padding: 5px; text-align: left;">
        <form id="search_form">
          <span style="font-size: 14px;">关键字</span>
          <input type="text" id="keyword" name="keyword" style="width: 120px; height: 24px;">
          <span style="font-size: 14px; margin-left: 5px;">状态</span>
          <select id="status" style="height: 27px; width: 100px;">
          </select>
          <span style="font-size: 14px; margin-left: 5px;">发布日</span>
          <select id="time_limit" style="height: 27px; width: 100px;">
          </select>
          <button type="button" id="btn_search" style="height: 27px; width: 50px; margin-left: 10px;">搜索</button>
        </form>
      </div>
      <div style="width: 100%; text-align: left;">
        <table id="search_result" class="display">
          <thead>
            <tr>
              <th>招标名称</th>
              <th>招标编号</th>
              <th>发布时间</th>
            </tr>
          </thead>
        </table>
      </div>
    </div>
    <div id="footer"><s:text name="copyright" /></div>
  </div>
</body>
</html>